import type { JSX } from 'vue/jsx-runtime'
import type { RuleObject } from 'ant-design-vue/es/form'
import type { DefaultOptionType } from 'ant-design-vue/es/select'
import type { Dayjs } from 'dayjs'
import type { ColProps } from 'ant-design-vue'

export interface OptionDto extends DefaultOptionType {
    item?: any
    value?: any
}

export interface FormItemDto {
    name: string | JSX.Element
    element: string
    readonly?: boolean
    required?: boolean
    labelCol?: ColProps
    width?: number | string
    field?: string
    value?:
        | string
        | number
        | boolean
        | string[]
        | number[]
        | null
        | Date[]
        | any[]
    colClass?: string
    span?: number
    type?: string
    multiple?: number | string | boolean
    optionsType?: string // 数据类型
    optionsOrigin?: string // 远程数据来源
    optionsData?: OptionDto[]
    options?: OptionDto[] // 实际参考选项
    class?: string
    labelClass?: string
    placeholder?: string
    rules?: RuleObject[]
    params?: any
    defaultValue?: boolean | number | string | string[] | number[] | Dayjs[] | null | (() => void) // 默认值，若为函数则使用返回值
    hidden?: boolean
    defaultHidden?: boolean
    ref?: any
    remote?: boolean // 是否远程搜索
    prefix?: string | JSX.Element
    suffix?: string | JSX.Element
    callback?: {
        click?: () => void
        change?: any
        input?: (evt: any) => void
        keydown?: ((evt: FocusEvent) => any) | undefined
        focus?: ((evt: FocusEvent) => any) | undefined
        blur?: ((evt: FocusEvent) => any) | undefined
        keyup?: ((evt: number | null | undefined) => any) | undefined
        init?: () => void
        submit?: () => void
        load?: () => void
        post?: () => void
        method?: (value: string) => Promise<OptionDto[]>
        remoteMethod?: (value: string) => void
    }
}
